package com.yuanfeng.userms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanfeng.commoms.exception.BizCodeEnume;
import com.yuanfeng.commoms.util.LimitUtils;
import com.yuanfeng.commoms.util.ParseTokenUtils;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.commoms.util.querypage.PageUtils;
import com.yuanfeng.commoms.util.querypage.Query;
import com.yuanfeng.commoms.vo.user.UserInfoVO;
import com.yuanfeng.userms.entity.UserMessageEntity;
import com.yuanfeng.userms.mapper.UserMessageMapper;
import com.yuanfeng.userms.service.UserMessageService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 *
 */
@Service
public class UserMessageServiceImpl extends ServiceImpl<UserMessageMapper, UserMessageEntity>
    implements UserMessageService{

    @Override
    public ResponseResult queryMessageContentListPort(Map<String, Object> param) {

        UserInfoVO userInfo = ParseTokenUtils.getPlatformUser(param.get("token").toString());
        if (LimitUtils.checkLimit("membermessage", userInfo)) {
            IPage<UserMessageEntity> page=this.baseMapper.queryMessageContentListPort(new Query<UserMessageEntity>().getPage(param),
                    param);;
            return ResponseResult.success(PageUtils.getPage(page));
        } else {
            return ResponseResult.fail(BizCodeEnume.INSUFFICIENT_PERMISSIONS);
        }

    }
}




